package com.cooper.scraper.show;

import com.cooper.android.comm.GalleryFlow;
import com.cooper.android.comm.Resource;
import com.cooper.scraper.R;

import android.content.Context;
import android.view.ViewGroup.LayoutParams;
import android.widget.Gallery;
import android.widget.RelativeLayout;

public class FlowGalleryViewFactory<T extends Resource> extends
		GalleryFanartShow<T> {
	
	private float fanartHieght;
	private float fanartWidth;

	public FlowGalleryViewFactory(Context context,
			FanartViewStrategy<T> fanartStrategy, int width, int height,
			float fanartScale) {
		super(context, fanartStrategy, width, height);
		fanartHieght = (height / (120 / 100)) / 3 * 2;
		fanartWidth = fanartHieght * fanartScale;
		init();
	}

	@Override
	public Gallery createAdapterView(Context context) {
		GalleryFlow gallery = new GalleryFlow(context);
		gallery.setBackgroundResource(R.drawable.showcase);
		gallery.setFadingEdgeLength(0);

		RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
				LayoutParams.FILL_PARENT, galleryHeight);
		lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
		lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
		gallery.setLayoutParams(lp);
		return gallery;
	}

	@Override
	public void destroy() {
		super.destroy();
	}

	@Override
	protected FanartImgStrategy getFanartImgStrategy() {
		return LightFanartImgStragety.getInstance();
	}

	@Override
	protected float getFanartWidth() {
		return fanartWidth;
	}

	@Override
	protected float getFanartHeight() {
		return fanartHieght;
	}

}
